/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sistema.ecua911.datos.BDs;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author pablo
 */
public class DataBaseManager {

    private String user = "ADMINISTRADOR";
    private String pass = "1234";
    private String servidor = "localhost";

    public DataBaseManager() {
    }

    public DataBaseManager(String Host, String Usuario, String Password) {
        user = Usuario;
        pass = Password;
        servidor = Host;
    }

    public void setParametrosConexion(String Host, String Usuario, String Password) {
        user = Usuario;
        pass = Password;
        servidor = Host;
    }

    public Connection AbrirConexion() throws SQLException {
        Connection conexion = null;
        if (user.compareTo("") == 0 || pass.compareTo("") == 0 || servidor.compareTo("") == 0) {
            JOptionPane.showMessageDialog(null, "Algunos de los datos de conexion se encuentra en blanco\n no se hizo la conexion");
        } else {
            DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
            conexion = DriverManager.getConnection("jdbc:oracle:thin:@" + this.servidor + ":1521:xe", user, pass);
            conexion.setAutoCommit(true);
            return conexion;
        }
        return conexion;
    }
}
